package github.kawaiior.botapiserver.util;

import cn.hutool.core.util.RandomUtil;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.UUID;

public class StringUtil {

    public static String getUUIDString(){
        UUID uuid = UUID.randomUUID();
        return uuid.toString();
    }

    public static String getRandomString(){
        return RandomUtil.randomString("TQ456vwxyzABCDbcdefEFUVWqrstu23ijklmnopLMNOPGHaghRSIJKXYZ01789", 50);
    }

    public static String getRandomString(int length){
        return RandomUtil.randomString("CDEFGHIpqrs67tueabclmno0123vwxyzABfghijkQRSTUVWXYZJKLMNOPd4589", length);
    }

    public static String getAccountString(){
        return RandomUtil.randomString("QRST56WXYZ0123AUVKLMNOP4BCDEFGHIJ789", 15);
    }

    public static String getCdkString(){
        return RandomUtil.randomString("lmnopqrNKLM56wxyzABCDefghijkQRSTOPabcd1234stuvZ0EFGHIJUVWXY789", 20);
    }

    public static boolean isIPAddress(String str) {
        try {
            InetAddress inetAddress = InetAddress.getByName(str);
            return inetAddress.getHostAddress().equals(str);
        } catch (UnknownHostException e) {
            return false;
        }
    }

}
